const mongoose = require('./db')
const Schema = mongoose.Schema
const UserSchema = new Schema({
    // 用户名
    username: {
        type: String,
        required: true
    },
    // 密码
    password: {
        type: String,
        required: true
    },
    // 用户本人姓名
    fullname: {
        type: String,
        required: true,
        default: ""
    },
    // 年龄
    age: {
        type: Number,
        default: ''
    },
    // 地址
    address: {
        type: Array,
        default: []
    },
    // 手机号
    phone: {
        type: String,
        required: true,
        default: ""
    },
    // email
    email: {
        type: String,
        required: true,
        default: ""
    },
    // 用户留言
    message: {
        type: String,
        default: ""
    },
    // 性别
    sex: {
        type: String,
        default: "woman"
    },
    // 购物车清单
    shoppingCart: {
        type: Array,
        default: []
    },
    // 已购买商品清单
    purchasedGoods: {
        type: Array,
        default: []
    },
    admin: {
        type: Boolean,
        default: false
    },
    // 注册时间
    registrationTime: {
        type: Date,
        required: true,
        default: Date.now
    }
})

module.exports = UserModel = mongoose.model('pdf_user', UserSchema)
